The present invention relates to a processing system for a portable electronic apparatus, e.g., an IC card.
Recently, an IC card incorporating an IC chip having a nonvolatile data memory and a control element such as a CPU (Central Processing Unit) has been developed. An IC card of this type is normally operated using a card reader/writer. This operation is performed by an instruction supplied from the card reader/writer. The IC card decodes an operation code (OP code) of the received instruction, and executes a series of processing corresponding to a function indicated by the OP code. Then, the IC card outputs the processed result to the card reader/writer as response data. In this case, a function code included in the input instruction is attached to the response data to make protection for the irregular sequence between the IC card and the card reader/writer. More specifically, the OP code is extracted from the instruction stored in a buffer upon an input of the instruction data, and the extracted OP code is attached to the processed result when the processed result is output to the card reader/writer.
However, with this method, when no OP code is included in the instruction from the card reader/writer (in the case of an illegal instruction), or when the instruction cannot be normally received due to transmission noise, wrong data may be output as the OP code. This is because a portion corresponding to the OP code of the instruction stored in the buffer is simply extracted, and is attached to the processed result as the OP code. For this reason, when a sequence between the card reader/writer and the IC card is disordered, the protection may be impossible. In particular, when instructions having the same OP code are successively transmitted a plurality of times, the sequence may often be disordered. When sequence disorder occurs upon transmission of data write instruction data, abnormality such as double writing of data occurs.